/**
 * Created by asus on 2017/9/27.
 */
public class Binary {


    public float answer(int item){

        float first = getnum(item);
        float last = first+1;
        float mid = (first+last)/2;
        float firsts = first*first;
        float lasts = last*last;
        float mids = mid*mid;

        for (int i=0;i<4;i++){
            if (mids>item){
                last = mid;
                lasts = mids;
                mid = (first+last)/2;
                mids = mid*mid;
            }
            if (mids<item){
                first = mid;
                firsts = first*first;
                mid = (first+last)/2;
                mids= mid*mid;
            }
        }
        return mid;

    }
    public void testgetnum(int i){
        System.out.println(getnum(i));
    }
    public static int getnum(int item){
        int num=0;
        int front=num*num;
        int after=(num+1)*(num+1);
        while ((front<item&&after<item)||(front>item&&after>item)){
            num++;
            front=num+num;
            after=(num+1)*(num+1);

        }
            return num;
        }


    public static void main(String[] args) {
        Binary binary = new Binary();
        System.out.println(binary.answer(5));
        binary.testgetnum(5);
    }
}
